export default (timestamp: string | number | Date, formats = "Y-m-d H") => {
	const DATE = timestamp ? new Date(timestamp) : new Date();
	let year = DATE.getFullYear();
	let month = (DATE.getMonth() + 1).toString().padStart(2, "0");
	let day = DATE.getDate().toString().padStart(2, "0");
	let hour = DATE.getHours().toString().padStart(2, "0");
	let minite = DATE.getMinutes().toString().padStart(2, "0");
	let second = DATE.getSeconds().toString().padStart(2, "0");
	let week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"][DATE.getDay()];
	return formats.replace(/Y|m|d|H|i|s/ig, (res: string): any => {

		return {
			"Y": year,
			"m": month,
			"d": day,
			"H": hour,
			"i": minite,
			"s": second,
			"w": week
		}[res]

	})
}